/**
 * Created by DukeCrushIt on 2015/7/22.
 */
module game{
    export class QZoneConfig{
        public constructor(){
        }
        public static init(){//防止TSC编译成js的时候不编译进去
        }

        public static onUserMark(result:any){
            if( result == null) return;
            Model.me.initFromData(result.rsp.user);
            if( BattleInstruction.getInstance().parent)
                BattleInstruction.getInstance().updateToggle();
        }

        public static showErrorRemind(content:string){
            if( content == null)  return;
            window["__showConnection"](false);
            if( Model.GuideStarted) return;
            RemindPanel.getInstance().showContent(content);
        }

        public static chargeResult(result:any){
            if( result == null) return;
            Model.CurOrderId = result.rsp.orderId;
            var goodId = result.rsp.propId;
            var data = Model.GetDiamondDataId(goodId);
            var needCost =  Math.ceil(data.disPrice * 0.8);//Model.me.is_vip ? Math.ceil(data.disPrice * 0.8) : data.disPrice;
            if( Model.me.score >= needCost){
                window["__pay"](Model.CurOrderId);
            }else{
                //needCost = needCost - Model.me.score;
                window["popPayTips"]({defaultScore:needCost});
            }
        }

        public static payResult(result:any){
            if( result == null) return;
            var user:any = result.rsp.user;
            if( user ){
                if( Model.me.diamond != user.diamond){
                    Model.me.diamond = user.diamond;
                }
                DiamondElement.getInstance().updateDisplay();
            }
            if(result.rsp.info){
                Model.userExt =  result.rsp.info;
                if( VipPanel.getInstance().parent)
                    VipPanel.getInstance().updateDisplay();
            }

            Model.CurOrderId = -1;
        }

        public static onPaySuccessBack(){
            if(  Model.CurOrderId!= -1 ){
                window["__pay"](Model.CurOrderId);
            }
        }

        public static buyPropResult(result:any){
            if( result == null) return;
            window["__showConnection"](false);
            var prop:any = result.rsp.prop;
            var user:any = result.rsp.user;
            var hair:any = result.rsp.hair;
            Model.updatePropCnt(prop.propId, prop.count);
            if( user != undefined){
                if( Model.me.diamond != user.diamond){
                    Model.me.diamond = user.diamond;
                }
            }

            if( hair != undefined){
                if(hair.type == Model.GOOD_TYPE_CAT){
                    Model.me.catHair = hair.hair;
                }else if( hair.type == Model.GOOD_TYPE_DOG){
                    Model.me.dogHair = hair.hair;
                }
            }

            DiamondElement.getInstance().updateDisplay();
            MainScene.getInstance().updatePropList();
            MainScene.getInstance().updateItems();
            ShowHint("购买成功");
            Model.checkGuide("buyok",prop.propId);
            Model.SYSTIME = result.date;
        }

        public static goodsInfo(goods:any){
            if( goods == null) return;
            window["__showConnection"](false);
            var goodsInfo:any[] = goods.rsp.goods;
            var len = goodsInfo.length;
            var goodInfo:GoodInfo;
            var good:any;
            for( var i:number=0; i < len; i++){
                good = goodsInfo[i];
                goodInfo = new GoodInfo(good);
                if(good.hidden && good.type != Model.GOOD_TYPE_DIAMOND){
                    if( good.type == Model.GOOD_TYPE_MONEY){
                        Model.moneys.push(goodInfo);
                    }else{
                        Model.hideGoods.push(goodInfo);
                    }
                }else if( good.type == Model.GOOD_TYPE_ITEM){
                    Model.goods.push(goodInfo);
                }else if(good.type == Model.GOOD_TYPE_CAT){
                    Model.cats.push(goodInfo);
                    if( goodInfo.classify == 12){
                        Model.TotalGuildCatCnt++;
                    }
                }else if( good.type == Model.GOOD_TYPE_DOG){
                    Model.dogs.push(goodInfo);
                    if( goodInfo.classify == 12){
                        Model.TotalGuildDogCnt++;
                    }
                }else if( good.type == Model.GOOD_TYPE_PRIZE){
                    Model.prize = goodInfo;
                }else if( good.type == Model.GOOD_TYPE_MONEY){
                    Model.moneys.push(goodInfo);
                }else if( good.type == Model.GOOD_TYPE_DIAMOND){
                    Model.diamonds.push(goodInfo);
                }else if( good.type == Model.GOOD_TYPE_DECORATE){
                    Model.decorators.push(goodInfo);
                    if( goodInfo.use4Cat){
                        Model.decorators4cat.push(goodInfo.id);
                    }
                    if( goodInfo.use4Dog){
                        Model.decorators4dog.push(goodInfo.id);
                    }
                }else if( good.type == Model.GOOD_TYPE_GUILD_CAT){
                    Model.cats.push(goodInfo);
                    Model.TotalGuildCatCnt++;
                }else if( good.type == Model.GOOD_TYPE_GUILD_DOG){
                    Model.dogs.push(goodInfo);
                    Model.TotalGuildDogCnt++;
                }else if( good.type == Model.GOOD_TYPE_GUILD_MATERIAL){
                    Model.guildMaterial.push(goodInfo);
                }else if( good.type == Model.GOOD_TYPE__GUILD_GOODS){
                    Model.guildGoods.push(goodInfo);
                }
            }

            Model.dogs.sort(function(item0,item1){
                if( item0.id < item1.id)
                    return -1;
                else
                    return 1;
            });
            Model.cats.sort(function(item0,item1){
               if( item0.id < item1.id)
                    return -1;
                else
                    return 1;
            });
            Model.moneys.sort(function(item0,item1){
                if( item0.id < item1.id)
                    return 1;
                else
                    return -1;
            });
            Model.diamonds.sort(function(item0,item1){
               if( item0.orders < item1.orders)
                    return 1;
                else
                    return -1;
            });
            Model.SYSTIME = goods.date;
            if( PetMgr.getInstance().pets && PetMgr.getInstance().pets .length!=0){
                PetMgr.getInstance().checkGuildPetCnt();
            }
        }

        public static updateUserInfo(useInfo:any){
            if( useInfo == null) return;
            window["__showConnection"](false);
           
            Model.me.initFromData(useInfo.rsp.user);
            Model.userExt =  useInfo.rsp.info;
            if( VipPanel.getInstance().parent)
                VipPanel.getInstance().updateDisplay();
            Model.curGuideStep = Model.me.step;
            if( DiamondElement.getInstance().parent)
                DiamondElement.getInstance().updateDisplay();
            Model.SYSTIME = useInfo.date;
        }

        public static onGetProps(result:any){
            if( result == null) return;
            window["__showConnection"](false);
            var props:any[] = result.rsp.props;
            var prop:any;
            var itemInfo:PropInfo;
            var len:number = props.length;
            for(var i:number=0; i<len; i++){
                prop = props[i];
                itemInfo = new PropInfo(prop);
                Model.props.push(itemInfo);
            }

            Model.SYSTIME = result.date;
        }

        public static onZoneInfo(result:any){
            if( result == null) return;
            window["__showConnection"](false);
            Model.me.score = result.rsp.info.score;
            Model.me.is_vip = result.rsp.info.is_vip;
            Model.me.vip_level = result.rsp.info.vip_level;
            Model.me.expiretime = result.rsp.info.expiretime;

            Model.SYSTIME = result.date;
        }
        public static onRankPage(result:any){
            if( result == null) return;
            window["__showConnection"](false);
            Model.SYSTIME = result.date;
            if( result.rsp.record != null && result.rsp.record != undefined){
                Model.me.name = result.rsp.record.name;
                Model.me.figureurl = result.rsp.record.figureurl;
            }

            var type:number = result.rsp.type;
            var list:any[] = result.rsp.list;
            var len:number = list.length;
            var idx:number;
            var info:RankInfo;
            if( type == 2) {
                if( Model.friendRank == null)
                    Model.friendRank = [];
                for(idx = 0; idx < len;idx++){
                    if( Model.friendRank.length > idx ){
                        Model.friendRank[idx].initFromData(list[idx]);
                    }else{
                        info = new RankInfo(list[idx]);
                        Model.friendRank.push(info);
                    }
                }
                //Model.UpdateMyRank();
            }else if(type == 1){
                if( Model.worldRank == null)
                    Model.worldRank = [];
                for(idx = 0; idx < len;idx++){

                    if( Model.worldRank.length > idx ){
                        Model.worldRank[idx].initFromData(list[idx]);
                    }else{
                        info = new RankInfo(list[idx]);
                        Model.worldRank.push(info);
                    }
                }
            }
        }

        public static onGift(result:any){
            if( result == null)
                return;
            window["__showConnection"](false);//todo 根据实际情况  道具的设计
            Model.SYSTIME = result.date;
        }
        public static onGuideBack(result:any){
            if( result == null) return;
            Model.me.msk = result.rsp.user.msk;
            Model.me.step = result.rsp.user.step;
            Model.curGuideStep = Model.me.step;
            Model.SYSTIME = result.date;
        }

        public static onBuyPet(result:any){
            if( result == null) return;
            if(Model.pets == undefined){
                Model.pets = [];
            }
            var pet:Pet = new Pet(result.rsp.pet);
            PetMgr.getInstance().addPet(pet);
            Model.pets.push(pet);
            if(Model.pets.length == 1)
                Model.me.myType = pet.type;

            if(CreateRoleScene.getInstance().parent != undefined)
                CreateRoleScene.getInstance().onBuyBack();
            if( TravelPanel.getInstance().parent != null){
                TravelPanel.getInstance().updatePageDisplay();
            }
            var hair = result.rsp.hair;
            if( hair != undefined){
                if(hair.type == Model.GOOD_TYPE_CAT){
                    Model.me.catHair = hair.hair;
                }else if( hair.typ == Model.GOOD_TYPE_DOG){
                    Model.me.dogHair = hair.hair;
                }
            }
            var petWar = result.rsp.petWar;
            if( petWar && Model.petAttributes){
                Model.petAttributes.push(petWar);
            }
            var user = result.rsp.user;
            if( user!=undefined){
                Model.me.diamond = user.diamond;
            }

            if( result.rsp.prop != undefined){
                Model.setPropCnt(result.rsp.prop.propId,result.rsp.prop.count);
                PetMgr.getInstance().onPropBack(result.rsp.prop.propId);
                MainScene.getInstance().updatePropList();
            }

            if( DiamondElement.getInstance().parent)
                DiamondElement.getInstance().updateDisplay();
            if( PlayBar.getInstance().parent && Model.pets.length == 1)
                PlayBar.getInstance().updateDisplay();
            SoundMgr.getInstance().playEffect(SoundMgr.UPGRADE);
            Model.SYSTIME = result.date;
        }

        public static onPetList(result:any){
            if( result == null ) return;
            var list:any[] = result.rsp.pets;
            Model.pets = [];
            var len = list.length;
            if( len != 0){
                window["__lattention"]();
            }
            var pet:Pet;
            var info:any;
            var referTime:number=0;
            for(var i = 0 ; i < len; i++){
                info = list[i];
                pet = new Pet(info);
                if( referTime == 0 || pet.buyTime < referTime){
                    referTime = info.buyTime;
                    Model.me.myType = pet.type;
                }
                Model.pets.push(pet);
                if( pet.inDate)
                    PetMgr.getInstance().curIndatePetId = pet.petId;
                if( pet.rear)
                    PetMgr.getInstance().addPet(pet);
            }
            Model.SYSTIME = result.date;
        }

        public static onHairs(result:any){
            if( result == null ) return;
            var list:any[] = result.rsp.hair;
            var len = list.length;
            var hair:any;
            for(var idx = 0; idx < len; idx++){
                hair = list[idx];
                if( hair != null && hair != undefined ){
                    if( hair.type == Model.GOOD_TYPE_DOG){
                        Model.me.dogHair = hair.hair;
                    }else if( hair.type == Model.GOOD_TYPE_CAT){
                        Model.me.catHair = hair.hair;
                    }
                }
            }
            if( DiamondElement.getInstance().parent)
                DiamondElement.getInstance().updateDisplay();

            Model.SYSTIME = result.date;
        }

        public static onFondleBack(result:any){
            if( result == null) return;
            var buff = result.rsp.buff;
            BuffMgr.getInstance().updateBuff(buff);
            var pet = result.rsp.pet;
            if( pet != undefined){
                PetMgr.getInstance().updatePet(result.rsp.pet);
                Model.checkGuide("fondle", result.rsp.pet.fondleMood);
                EffectMgr.getInstance().playEffect("mood",3,0,SoundMgr.getInstance(),SoundMgr.getInstance().playEffect,SoundMgr.USEITEM);
            }

            Model.SYSTIME = result.date;
        }
        public static onClickBack(result:any){
            if(result == null) return;
            var pet:any = result.rsp.pet;
            if( pet != undefined){
                PetMgr.getInstance().updatePet(pet);
                Model.checkGuide("click",pet.clickTimes);
            }
            Model.SYSTIME = result.date;
        }

        public static onAutoBack(result:any){
            if(result == null) return;
            var list:any[] = result.rsp.list;
            var len=list.length;
            var petdata:any;
            for(var idx=0; idx<len; idx++){
                petdata = list[idx];
                PetMgr.getInstance().updatePet(petdata);
            }
            PlayBar.getInstance().updateSpeed();
            Model.SYSTIME = result.date;
        }

        public static onGleanBack(result:any){
            if(result == null) return;
            var pet:any = result.rsp.pet;
            if( pet != null){
                PetMgr.getInstance().updatePet(pet);
                var type = result.rsp.type;
                if( type == 1){
                    Model.cleanProduceHairData(pet.petId);
                }
            }
            var hair:any = result.rsp.hair;
            if( hair != null && hair != undefined ){
                if( hair.type == Model.GOOD_TYPE_DOG){
                    Model.me.dogHair = hair.hair;
                }else if( hair.type == Model.GOOD_TYPE_CAT){
                    Model.me.catHair = hair.hair;
                }
                DiamondElement.getInstance().updateDisplay();
            }
            Model.checkGuide("glean",Model.me.dogHair || Model.me.catHair);
            Model.SYSTIME = result.date;
        }

        public static onUpgradeBack(result:any){
            if(result == null) return;
            var hair:any = result.rsp.hair;
            if( hair.type == Model.GOOD_TYPE_CAT){
                Model.me.catHair = hair.hair;
            }else if( hair.type == Model.GOOD_TYPE_DOG){
                Model.me.dogHair = hair.hair;
            }
            var pet:any = result.rsp.pet;//根据id更新宠物 更新商店面板
            PetMgr.getInstance().updatePet(pet);
            if( TravelPanel.getInstance().parent != null){
                TravelPanel.getInstance().updatePageDisplay();
            }
            //if( PlayBar.getInstance().parent != null)
            //    PlayBar.getInstance().updateHairNum();
            DiamondElement.getInstance().updateDisplay();
            Model.checkGuide("upgrade");
            SoundMgr.getInstance().playEffect(SoundMgr.UPGRADE);
            Model.SYSTIME = result.date;
        }

        public static onIndateBack(result:any){
            if( result == null) return;
            Model.SYSTIME = result.date;
            PetMgr.getInstance().updatePet(result.rsp.pet);
            PetMgr.getInstance().curIndatePetId = result.rsp.pet.petId;
            DateScene.getInstance().onIndateBack();
            DateScene.getInstance().updateWarRelated();
        }

        public static onDateBack(result:any){
            if( result == null) return;

            var hair:any = result.rsp.hair;
            if( hair.type == Model.GOOD_TYPE_CAT){
                Model.me.catHair = hair.hair;
            }else if( hair.type == Model.GOOD_TYPE_DOG){
                Model.me.dogHair = hair.hair;
            }
            DiamondElement.getInstance().updateDisplay();

            SceneMgr.getInstance().switchScene(SceneMgr.SCENE_OTHERS,result.rsp);
            Model.datedList.push(result.rsp.record.dateUserId);
            Model.inDating = true;
            Model.userExt = result.rsp.info;
            DateScene.getInstance().onDateBack();
            //Model.DeleteDateItem(PetMgr.getInstance().othersPet);
            Model.checkGuide("date");
            Model.SYSTIME = result.date;
        }

        public static onDateList(result){
            if( result == null) return;
            Model.strangerList = [];
            Model.cdTime = result.rsp.cdTime;
            var list = result.rsp.list;
            var len = list.length;
            var pet:Pet;
            for(var idx = 0; idx < len; idx++){
                pet = new Pet(list[idx]);
                Model.strangerList.push(pet);
            }
            //if( PetShopScene.getInstance().parent != null && PetShopScene.getInstance().currentType == SceneMgr.SCENE_GETOUT)
            //    PetShopScene.getInstance().onDateListBack();
            if( DateScene.getInstance().parent)
                DateScene.getInstance().onDateRefreshBack();
            Model.SYSTIME = result.date;
        }

        public static onDateInfo(result){
            if( result == null) return;
            Model.SYSTIME = result.date;
            var list = result.rsp.list;
            Model.strangerList = [];
            var len = list.length;
            var pet:Pet;
            for(var idx = 0; idx < len; idx++){
                pet = new Pet(list[idx]);
                Model.strangerList.push(pet);
            }
            Model.cdTime = result.rsp.cdTime;
            Model.datedList = result.rsp.dateds;
            Model.robedList = result.rsp.pillages;
            Model.userExt = result.rsp.info;
            //if( PetShopScene.getInstance().parent != null && PetShopScene.getInstance().currentType == SceneMgr.SCENE_GETOUT)
            //    PetShopScene.getInstance().onDateListBack();
            if( DateScene.getInstance().parent)
                DateScene.getInstance().onDateInfoBack();
        }
        public static onSweep(result){
            if( result == null) return;

            var hair:any = result.rsp.hair;
            if( hair){
                if( hair.type == Model.GOOD_TYPE_CAT){
                    Model.me.catHair = hair.hair;
                }else if( hair.type == Model.GOOD_TYPE_DOG){
                    Model.me.dogHair = hair.hair;
                }
                DiamondElement.getInstance().updateDisplay();
            }

            PetMgr.getInstance().onSweepBack(result.rsp.shitHair);
            Model.SYSTIME = result.date;
        }
        public static onPetCount(result:any){
            if( result == null) return;
            // BigdataScene.getInstance().updateCntGroup(result.rsp);
            Model.SYSTIME = result.date;
        }
        public static onPetSex(result:any){
            if( result == null) return;
            // BigdataScene.getInstance().updateGenderGroup(result.rsp);
            Model.SYSTIME = result.date;
        }
        public static onPetHairs(result:any){
            if( result == null) return;
            // BigdataScene.getInstance().updateGdpGroup(result.rsp);
            Model.SYSTIME = result.date;
        }
        public static onUserHair(result:any){
            if( result == null) return;
            // BigdataScene.getInstance().updateUserHairGroup(result.rsp);
            Model.SYSTIME = result.date;
        }
        public static onUserPopularity(result:any){
            if( result == null) return;
            // BigdataScene.getInstance().updateZanGroup(result.rsp);
            Model.SYSTIME = result.date;
        }
        public static onRobHairs(result:any){
            if( result == null) return;
            // BigdataScene.getInstance().updateRobGroup(result.rsp);
            Model.SYSTIME = result.date;
        }
        public static onPetHair(result:any){
            if( result == null) return;
            // BigdataScene.getInstance().updatePetHairGroup(result.rsp);
            Model.SYSTIME = result.date;
        }
        public static onPetFondle(result:any){
            if( result == null) return;
            //BigdataScene.getInstance().updateFoundlerGroup(result.rsp);
            Model.SYSTIME = result.date;
        }

        public static onPropUseResult(result:any){
            if( result == null) return;
            var buff = result.rsp.buff;
            if( buff != undefined){
                BuffMgr.getInstance().addBuff(buff);
                if( buff.buffId ==BuffMgr.NO_WAR_BUFF){
                    ShowHint("您已高挂免战牌，别人没办法抢走你的毛啦");
                    if( MainScene.getInstance().parent != null) {
                        MainScene.getInstance().updateNoWarBuff();
                    }
                }
                RedPointMgr.getInstance().update(RedPointMgr.MOOD_BUFF,true);
            }

            if( result.rsp.prop != undefined){
                Model.setPropCnt(result.rsp.prop.propId,result.rsp.prop.count);
                PetMgr.getInstance().onPropBack(result.rsp.prop.propId);
                MainScene.getInstance().updatePropList();
            }

            var hair:any = result.rsp.hair;
            if( hair != undefined){
                PetMgr.getInstance().onPropUseBack(result.rsp.hair);
            }

            if( result.rsp.pet != undefined){
                PetMgr.getInstance().updatePet(result.rsp.pet);
            }
            Model.checkGuide("useprop");
            MainScene.getInstance().updateItems();
            Model.SYSTIME = result.date;
        }
        public static onBuffsBack(hehe){
            if(hehe == null) return;
            var list:any[] = hehe.rsp.buffs;
            var buff:any;
            var len = list.length;
            for( var idx = 0 ; idx < len; idx++){
                buff = list[idx];
                BuffMgr.getInstance().updateBuff(buff);
            }
            if( MainScene.getInstance().parent != null){
                MainScene.getInstance().updateNoWarBuff();
                //MainScene.getInstance().updateItems();
            }
            Model.SYSTIME = hehe.date;
        }
        public static onFigureBack(hehe){
            if(hehe == null) return;
        }

        public static onSloganBack(result){
            if( result == null) return;
            Model.SYSTIME = result.date;
            PetMgr.getInstance().updatePet(result.rsp.pet);
        }

        public static onMissionModels(result){
            if( result == null) return;
            Model.SYSTIME = result.date;
            var list:any[] = result.rsp.list;
            var len = list.length;
            var info;
            var mission:MissionInfo;
            Model.missionModels = {};
            Model.achieveModels = {};
            Model.unlockModels = {};
            for(var idx = 0 ; idx < len; idx++){
                info = list[idx];
                mission = new MissionInfo(info);
                if( mission.type == Model.TYPE_MISSION){
                    Model.missionModels[info.id]=mission;
                }else if( mission.type == Model.TYPE_ACHIVEMENT ){
                    Model.achieveModels[info.id]=mission;
                }else if( mission.type == Model.TYPE_UNLOCK){
                    Model.unlockModels[info.id]=mission;
                }
            }
            if(QZoneConfig.tempMissionlistResult!= null){
                QZoneConfig.tempMissionlistResult.date = result.date;
                QZoneConfig.onMissionlist(QZoneConfig.tempMissionlistResult);
            }
        }
        public static tempMissionlistResult:any;
        public static onMissionlist(result){
            if( result == null) return;
            Model.SYSTIME = result.date;
            if( !Model.missionModels){
                QZoneConfig.tempMissionlistResult = result;
                return;
            }else{
                QZoneConfig.tempMissionlistResult = null;
            }
            var list:any[]=result.rsp.list;
            var len = list.length;
            var info;
            var mission:MissionInfo;
            Model.curAchievements = [];
            Model.curMissions = [];
            Model.finishedMissions = result.rsp.missionIds;
            for(var idx = 0 ; idx < len; idx++){
                info = list[idx];
                if( info.type == Model.TYPE_MISSION){
                    mission = Model.missionModels[info.missionId];
                    if( mission != null)
                        Model.curMissions.push(mission.id);
                    else
                        console.log("can't find mission:",info.missionId);
                }else if( info.type == Model.TYPE_ACHIVEMENT ){
                    mission = Model.achieveModels[info.missionId];
                    if( mission != null){
                        if(info.status != 1)
                            Model.curAchievements.push(mission.id);
                        else
                            Model.curAchievements.unshift(mission.id);
                    }
                    else
                        console.log("can't find mission:",info.missionId);
                }else if( info.type == Model.TYPE_UNLOCK){
                    mission = Model.unlockModels[info.missionId];
                    if( mission == null)
                        console.log("can't find unlock mission:",info.missionId);
                }else if( info.type == 104){
                    continue;
                }
                mission.status = info.status;
                mission.currStep = info.currStep || 0;
                //mission.steps = info.steps;
            }
            list =  result.rsp.missionIds;
            len =  list.length;
            var id;
            for(idx=0; idx < len; idx++){
                id = list[idx];
                mission = Model.missionModels[id];
                if( !mission) continue;
                mission.status = 2;
                if( mission){
                    Model.curMissions.push(id);
                }
            }
            if( ActivityPanel.getInstance().parent != null){
                ActivityPanel.getInstance().updateMissions();
            }
            if( MainScene.getInstance().parent){
                MainScene.getInstance().checkRequestLimitHair();
            }
        }

        public static onMissionAward(result){
            if( result == null) return;
            Model.SYSTIME = result.date;
            var user:any = result.rsp.user;
            if( user != undefined){
                if( Model.me.diamond != user.diamond){
                    Model.me.diamond = user.diamond;
                }
            }

            var hair:any = result.rsp.hair;
            if( hair != undefined){
                if( hair.type == Model.GOOD_TYPE_CAT){
                    Model.me.catHair = hair.hair;
                }else if( hair.type == Model.GOOD_TYPE_DOG){
                    Model.me.dogHair = hair.hair;
                }
            }
            DiamondElement.getInstance().updateDisplay();

            var props:any[] = result.rsp.props;
            if( props != undefined){
                var prop:any;
                var itemInfo:PropInfo;
                var len:number = props.length;
                for(var i:number=0; i<len; i++){
                    prop = props[i];
                    Model.setPropCnt(prop.propId,prop.count);
                }
            }
            var missionId = result.rsp.missionId;
            var type = parseInt((missionId+"").substring(0,3));
            if( type == Model.TYPE_MISSION){
                var mission = Model.missionModels[missionId];
                if(  Model.curMissions.indexOf(missionId) == -1){
                    Model.curMissions.push(mission.id);
                }
            }else if( type == Model.TYPE_ACHIVEMENT ){
                mission = Model.achieveModels[missionId];
                var index = Model.curAchievements.indexOf(missionId);
                Model.curAchievements.splice(index,1);
            }else if( type == Model.TYPE_UNLOCK){
                mission = Model.unlockModels[missionId];
            }
            mission.status = 2;
            Model.finishedMissions.push(missionId);
            if( type == Model.TYPE_ACHIVEMENT){
                if(ActivityPanel.getInstance().parent){
                    ActivityPanel.getInstance().updateMissions();
                }
            }else{
                if(  TravelPanel.getInstance().parent){
                    TravelPanel.getInstance().updateList();
                }
            }
            var config =  ActivityMgr.getInstance().getActivityConfigById(ActivityMgr.ACTIVITY_LIMIT_BUY_HAIR);
            var arr:number[];
            if( Model.me.myType == Model.GOOD_TYPE_CAT){
                arr = config.config[0].catMissionIds;
            }else{
                arr = config.config[0].dogMissionIds;
            }
            if( arr.indexOf(missionId) != -1){
                var len =  arr.length;
                var needShow = true;
                for(var i=0; i< len; i++){
                    if(Model.finishedMissions.indexOf(arr[i]) == -1){
                        needShow = false;
                        break;
                    }
                }
                if( needShow ){
                    if( !ActivityMgr.getInstance().limitHairBuyInfo){
                        window["__limitHairInfo"]();
                    }
                    setTimeout(function() {
                        LimitBuyHair.getInstance().show()
                    },500);
                }
                
            }
        }

        public static onSignInfo(result){
            if( result == null) return;
            Model.SYSTIME = result.date;
            var list:any[]=result.rsp.configs;
            var len = list.length;
            var info;
            var signInfo:SignInfo;
            Model.signInfos = [];
            for(var idx = 0 ; idx < len; idx++){
                info = list[idx];
                signInfo = new SignInfo(info);
                Model.signInfos.push(signInfo);
            }
            Model.totalSignCount = result.rsp.sign.count;
            Model.lastSignTime = result.rsp.sign.lastSignTime;
            var date:Date = new Date();
            date.setTime(Model.lastSignTime);
            var date1:Date = new Date();
            date1.setTime(Model.SYSTIME);
            Model.todaySigned = date.getDate() == date1.getDate() && date.getMonth() == date1.getMonth() && date.getFullYear() == date1.getFullYear();
            Model.resetDays = Math.floor(30 - (Model.SYSTIME - result.rsp.sign.lastResetTime)/3600000/24);
            if( SignPanel.getInstance().parent != null )
                SignPanel.getInstance().updateDisplay();
        }

        public static onSign(result){
            if( result == null) return;
            Model.SYSTIME = result.date;
            Model.totalSignCount = result.rsp.sign.count;
            Model.lastSignTime = result.rsp.sign.lastSignTime;
            Model.todaySigned = true;
            SignPanel.getInstance().updateDisplay();

            if( result.rsp.prop != undefined){
                Model.setPropCnt(result.rsp.prop.propId,result.rsp.prop.count);
                PetMgr.getInstance().onPropBack(result.rsp.prop.propId);
                MainScene.getInstance().updatePropList();
            }

            var ornament:any[] = result.rsp.ornament;
            if( ornament){
                Model.addFreeDec(ornament);
            }

            var user:any = result.rsp.user;
            if( user != undefined){
                if( Model.me.diamond != user.diamond){
                    Model.me.diamond = user.diamond;
                }
            }

            var hair:any = result.rsp.hair;
            if( hair != undefined){
                if( hair.type == Model.GOOD_TYPE_CAT){
                    Model.me.catHair = hair.hair;
                }else if( hair.type == Model.GOOD_TYPE_DOG){
                    Model.me.dogHair = hair.hair;
                }
            }
            DiamondElement.getInstance().updateDisplay();
        }

        public static onMailList(result:any){
            if( result == null) return;
            Model.SYSTIME = result.date;
            if( !Model.curMails){
                Model.curMails=[];
                Model.mailMap = {};
            }

            var list:any[] = result.rsp.list;
            var mailInfo:MailInfo;
            var len = list.length;

            for(var idx = 0; idx < len; idx++){
                if( !Model.mailMap[list[idx].id]){
                    mailInfo = new MailInfo(list[idx]);
                    Model.curMails.push(mailInfo);
                    Model.mailMap[mailInfo.id] = true;
                }
            }
            Model.moreMails = list.length == Model.MailPage;

            if( MailScene.getInstance().parent != null){
                MailScene.getInstance().updateMails();
            }
        }

        public static onReadMail(result:any){
            if( result == null) return;
            Model.SYSTIME = result.date;
            var mailId = result.rsp.mailId;
            var fucker = Model.DeleteMailById(mailId);
            if( fucker && MailScene.getInstance().parent != null ){
                MailScene.getInstance().updateMails();
            }
        }
        public static onDeleteMail(result:any){
            if( result == null) return;
            Model.SYSTIME = result.date;
            var mailIds = result.rsp.mailIds;
            var mailId;
            while(mailIds.length) {
                mailId = mailIds.pop();
                Model.DeleteMailById(mailId);
            }
            if( MailScene.getInstance().parent)
                MailScene.getInstance().updateMails();
        }

        public static onMailAward(result:any){
            if( result == null) return;//todo test
            Model.SYSTIME = result.date;
            var mailId = result.rsp.mailId;

            var fucker = Model.DeleteMailById(mailId);
            if( fucker && MailScene.getInstance().parent != null ){
                MailScene.getInstance().updateMails();
            }

            var hair:any = result.rsp.hair;
            if( hair != undefined){
                if( hair.type == Model.GOOD_TYPE_CAT){
                    Model.me.catHair = hair.hair;
                }else if( hair.type == Model.GOOD_TYPE_DOG){
                    Model.me.dogHair = hair.hair;
                }
            }
            var user:any = result.rsp.user;
            if( user != undefined){
                if( Model.me.diamond != user.diamond){
                    Model.me.diamond = user.diamond;
                }
            }

            DiamondElement.getInstance().updateDisplay();
            var props:any[] = result.rsp.props;
            if( props != undefined){
                var prop:any;
                var itemInfo:PropInfo;
                var len:number = props.length;
                for(var i:number=0; i<len; i++){
                    prop = props[i];
                    Model.setPropCnt(prop.propId,prop.count);
                }
            }
        }

        public static onChangeRearBack(result:any){
            if( result == null) return;
            Model.SYSTIME = result.date;
            var pet = result.rsp.pet;
            PetMgr.getInstance().onChangeReer(pet);//todo update list
            TravelPanel.getInstance().updateRearInfo();
        }

        public static onUnlocks(result:any){
            if( result == null) return;
            Model.SYSTIME = result.date;
            Model.UnlockConfigs = result.rsp.list;
            if( TravelPanel.getInstance().parent)
                TravelPanel.getInstance().updateList();
        }

        public static onDecorateModels(result:any){
            if( result == null) return;
            Model.SYSTIME = result.date;
            Model.decModels = result.rsp.list;
        }

        public static onDecUnlocks(result:any){
            if( result == null) return;
            Model.SYSTIME = result.date;
            Model.decUnlockConfig = result.rsp.list;
        }

        public static onDressed(result:any){
            if( result == null) return;
            Model.SYSTIME = result.date;
            var ornaments = result.rsp.ornaments;

            var len = ornaments.length;
            var info;
            var dec;
            for(var i = 0; i < len; i++){
                info = ornaments[i];
                if( info.petId != 0){
                    if( Model.HasFreeDec(info.goodsId)){
                        dec = Model.DeleteFreeDec(info.goodsId);
                    }else{
                        dec = null;
                    }
                    if( dec){
                        dec.initFromData(info);
                        Model.currentDecorators.push( dec );
                    }else{
                        Model.currentDecorators.push( new DecorateInfo(info) );
                    }
                }else{
                    dec = Model.DeleteDec(info.goodsId);
                    if(dec){
                        dec.initFromData(info);
                    }else{
                        dec = new DecorateInfo(info);
                    }
                    if( Model.myDecorates.indexOf(dec) == -1)
                        Model.myDecorates.push(dec);
                }
            }
            if(!Model.petAttributes)
                Model.petAttributes = [];
            if( DecorateScene.getInstance().parent)
                DecorateScene.getInstance().onDressBack();
            else if( MainScene.getInstance().parent)
                MainScene.getInstance().updateItems();

            var war = result.rsp.war;
                if( war){
                var len = Model.petAttributes.length;
                var found;
                var iwar;
                for(var i = 0; i < len; i++){
                    iwar = Model.petAttributes[i];
                    if( iwar.petId == war.petId){
                        Model.petAttributes[i] = war;
                        found = true;
                        break;
                    }
                }
                if( !found){
                    Model.petAttributes.push(war);
                }
                if( PlayBar.getInstance().parent)
                    PlayBar.getInstance().updateDecorateRelated();
            }
            var pet = result.rsp.pet;
            if( pet){
                PetMgr.getInstance().updatePet(pet);
                PlayBar.getInstance().updateSpeed();
            }
            Model.checkGuide("save_complete");
            ShowHint("保存装扮成功");
        }
        /** 战斗属性 **/
        public static onlwars(result:any){
            if( result == null) return;
            Model.SYSTIME = result.date;
            Model.petAttributes = result.rsp.list;
            if( PlayBar.getInstance().parent)
                PlayBar.getInstance().updateDecorateRelated();
            if( DateScene.getInstance().parent)
                DateScene.getInstance().updateWarRelated();
        }
        /** 已装备的装饰品 **/
        public static onDocorates(result:any){
            if( result == null) return;
            Model.SYSTIME = result.date;
            Model.myDecorates = [];
            Model.currentDecorators = [];
            var decorates = result.rsp.list;
            var len = decorates.length;
            var info;
            for(var i = 0; i < len; i++){
                info = decorates[i];
                if( info.petId == 0){
                    Model.myDecorates.push(new DecorateInfo(info));
                }else{
                    Model.currentDecorators.push( new DecorateInfo(info));
                }
            }
            if( MainScene.getInstance().parent)
                MainScene.getInstance().updateItems();
            else if( DecorateScene.getInstance().parent)
                DecorateScene.getInstance().updateItems();
        }

        public static onDecoratesBuy(result:any){
            if( result == null) return;
            Model.SYSTIME = result.date;
            var user:any = result.rsp.user;
            var flag = result.rsp.flag;
            if( user ){
                Model.me.initFromData(user);
            }
            PlayBar.getInstance().updateMeng();
            var hair:any = result.rsp.hair;
            if( hair ){
                if( hair.type == Model.GOOD_TYPE_CAT){
                    Model.me.catHair = hair.hair;
                }else if( hair.type == Model.GOOD_TYPE_DOG){
                    Model.me.dogHair = hair.hair;
                }
            }
            DiamondElement.getInstance().updateDisplay();

            var decorates = result.rsp.ornaments;
            if( decorates ){
                var len = decorates.length;
                var info;
                var dressObj = {};
                for(var i = 0; i < len; i++){
                    info = decorates[i];
                    if( flag == 0){
                        Model.addFreeDec(info);
                    }else if( flag == 1){
                        dressObj[info.classify] = info.goodsId;
                    }
                }
            }

            //var prop:any = result.rsp.prop;
            //if( prop){
            //    Model.updatePropCnt(prop.propId, prop.count);
            //}

            if( flag == 1){
                window["__dressup"](PetMgr.getInstance().curPet.petId,JSON.stringify(dressObj));
            }else{
                ShowHint("购买成功");
            }
            if( DecorateScene.getInstance().parent)
                DecorateScene.getInstance().onBuyBack(flag);
        }

        public static onAttentionBack(result){
            Model.SYSTIME = result.date;
            Model.attentionIdList.push(result.rsp.data.attentionId);
            Model.attentionList.push(result.rsp.data);
            if( result.rsp.data.mutual){
                Model.allAttentionIdList.push(result.rsp.data.attentionId);
            }
            DateScene.getInstance().onAttentionBack(0);
            ShowHint("关注成功");
        }

        public static onUnattentionBack(result){
            Model.SYSTIME = result.date;
            var id = result.rsp.attentionId;
            var index = Model.attentionIdList.indexOf(id);
            if( index != -1){
                Model.attentionIdList.splice(index,1);
                Model.attentionList.splice(index,1);
            }
            DateScene.getInstance().onAttentionBack(1);
            ShowHint("取消关注成功");
        }

        public static onPraiseBack(result){
            Model.SYSTIME = result.date;
            DateScene.getInstance().onPraiseBack(result.rsp.info, result.rsp.popularity)
        }

        public static onGiftBack(result){
            Model.SYSTIME = result.date;
        }

        public static onCleanCdBack(result){
            Model.SYSTIME = result.date;
            Model.me.diamond = result.rsp.user.diamond;
            Model.userExt = result.rsp.info;//todo check this poperty
            DiamondElement.getInstance().updateDisplay();
            DateScene.getInstance().onRob(null);
        }

        public static onStartPillageBack(result) {
            Model.SYSTIME = result.date;
            Model.checkGuide("rob");
            DateScene.getInstance().onPillageStartBack(result.rsp.game);
            Model.checkGuide("enter_battle");
        }

        public static onForcePillageBack(result) {
            Model.SYSTIME = result.date;
            var robId = result.rsp.pillagerId;
            window["__pillage"](robId);

            var user = result.rsp.user;
            if( user != undefined){
                Model.me.diamond = user.diamond;
                DiamondElement.getInstance().updateDisplay();
            }
        }

        public static onFinishPillageBack(result){
            Model.SYSTIME = result.date;
            var hair = result.rsp.petHair;
            if( hair ){
                if( hair.type == Model.GOOD_TYPE_CAT){
                    Model.me.catHair = hair.hair;
                }else if( hair.type == Model.GOOD_TYPE_DOG){
                    Model.me.dogHair = hair.hair;
                }
            }
            Model.checkGuide("robbed");
            BattleScene.getInstance().showResult(result.rsp.hairs);
        }

        public static onRevengeBack(result){
            Model.SYSTIME = result.date;
            Model.REVENGE_DATA = result.rsp.game;
            var mailId = result.rsp.mailId;
            var fucker = Model.DeleteMailById(mailId);
            if( fucker && MailScene.getInstance().parent != null ){
                MailScene.getInstance().updateMails();
            }
            SceneMgr.getInstance().switchScene(SceneMgr.SCENE_BATTLE);
        }

        public static onAttentionList(result){
            Model.SYSTIME = result.date;
            var arr = result.rsp.list;
            var len = arr.length;
            Model.attentionList = arr;
            for(var i = 0 ; i < len; i++){
                Model.attentionIdList.push(arr[i].attentionId);
                if( arr[i].mutual){
                    Model.allAttentionIdList.push(arr[i].attentionId);
                }
            }
        }

        public static onPopularityBack(result){
            Model.SYSTIME = result.date;
        }

        public static onPopularityRankBack(result){
            Model.SYSTIME = result.date;
            if( ContributionPanel.getInstance().parent){
                ContributionPanel.getInstance().onContributeListBack(result.rsp.contributions,result.rsp.popularity);
            }
        }

        public static onVisitBack(result){
            Model.SYSTIME = result.date;
            DateScene.getInstance().onVisitBack(result.rsp.pet,
                result.rsp.petWar,
                result.rsp.popularity,
                result.rsp.ornaments,
                null,
                result.rsp.hair,
                result.rsp.search,
                result.rsp.pillageHair,
                result.rsp.peaceCardBuff,
                result.rsp.shieldBuff,
                result.rsp.logoId);
        }

        public static onBlockList(result){
            Model.SYSTIME = result.date;
            ChatMgr.getInstance().blockList = result.rsp.list;
        }
        public static onBlockBack(result){
            Model.SYSTIME = result.date;
            ChatMgr.getInstance().addBlock(result.rsp.data);
            ShowHint("该玩家已拉黑");
        }
        public static onUnblockBack(result){
            Model.SYSTIME = result.date;
            ShowHint("该玩家已移出黑名单");
            ChatMgr.getInstance().removeFromBlock(result.rsp.userId);
        }
        public static onActivityList(result){
            Model.SYSTIME = result.date;
            ActivityMgr.getInstance().setup(result.rsp.list);
            if( MainScene.getInstance().parent){
                MainScene.getInstance().checkRequestLimitHair();
            }
            window["__chargeInfo"]();
        }
        public static onChargeInfo(result){
            Model.SYSTIME = result.date;
            ActivityMgr.getInstance().setConfigAndInfo(result.rsp);
            if( MainScene.getInstance().parent){
                MainScene.getInstance().updateRechargeRelated();
            }

        }
        public static onChargeAward(result){
            Model.SYSTIME = result.date;
            var charge = result.rsp.charge;
            ActivityMgr.getInstance().chargeInfo = charge;

            var user = result.rsp.user;
            if( user != undefined){
                Model.me.diamond = user.diamond;
                Model.me.vipLevel = user.vipLevel;
                Model.me.vipScore = user.vipScore;
                DiamondElement.getInstance().updateDisplay();
            }

            var props = result.rsp.props;
            if( props){
                var prop:any;
                var len:number = props.length;
                for(var i:number=0; i<len; i++){
                    prop = props[i];
                    Model.setPropCnt(prop.propId,prop.count);
                }
                if( MainScene.getInstance().parent)
                    MainScene.getInstance().updatePropList();
            }

            var decorates:any[] = result.rsp.ornaments;
            if( decorates){
                var len = decorates.length;
                var info;
                for(var i = 0; i < len; i++){
                    info = decorates[i];
                    Model.addFreeDec(info);
                }
            }

            if( FirstRechargePanel.getInstance().parent)
                FirstRechargePanel.getInstance().onClose(null);
            if( MainScene.getInstance())
                MainScene.getInstance().updateRechargeRelated();
            if( TotalRechargePanel.getInstance().parent)
                TotalRechargePanel.getInstance().updateDisplay();
        }
        public static onVipConfig(result){
            Model.SYSTIME = result.date;
            ActivityMgr.getInstance().setVipConfigs(result.rsp);
        }
        public static onVipInfo(result){
            Model.SYSTIME = result.date;
            var data = result.rsp.data;
            ActivityMgr.getInstance().vipInfo = data;
            var status = data.dailyLoginStatus == 1 || data.successionLoginStatus == 1 || data.pillageWinStatus == 1;
            RedPointMgr.getInstance().update(RedPointMgr.VIP_MISSION,status);
            if( VipPanel.getInstance().parent)
                VipPanel.getInstance().updateScoreRelated();
        }
        public static onVipScore(result){
            Model.SYSTIME = result.date;
            ActivityMgr.getInstance().vipInfo = result.rsp.score;
            var user = result.rsp.user;
            if( user != undefined){
                Model.me.diamond = user.diamond;
                Model.me.vipLevel = user.vipLevel;
                Model.me.vipScore = user.vipScore;
                DiamondElement.getInstance().updateDisplay();
            }
            if(result.rsp.info){
                Model.userExt =  result.rsp.info;
                if( VipPanel.getInstance().parent)
                    VipPanel.getInstance().updateDisplay();
            }


            if( VipPanel.getInstance().parent)
                VipPanel.getInstance().updateScoreRelated();
        }

        public static onMoneyCatInfo(result){
            Model.SYSTIME = result.date;
            ActivityMgr.getInstance().moneyCatInfo = result.rsp.data;
            MainScene.getInstance().checkMoneyCatShow();
            if( MoneyCatPanel.getInstance().parent)
                MoneyCatPanel.getInstance().updateDisplay();
        }

        public static onMoneyCatAward(result){
            Model.SYSTIME = result.date;
            ActivityMgr.getInstance().moneyCatInfo = result.rsp.cat;
            MainScene.getInstance().checkMoneyCatShow();
            var user = result.rsp.user;
            if( user){
                RemindPanel.getInstance().showContent("本喵给你招到了"+result.rsp.diamond+"个钻石！欢迎下次再来呀~喵！");
                Model.me.initFromData(user);
                if( DiamondElement.getInstance().parent)
                    DiamondElement.getInstance().updateDisplay();
            }
        }

        public static onWashInfo(result){
            Model.SYSTIME = result.date;
            if( GoldenFingerPanel.getInstance().parent)
                GoldenFingerPanel.getInstance().updateDisplay(result.rsp.data);
        }

        public static onWashBack(result){
            Model.SYSTIME = result.date;
            var hair = result.rsp.hair;
            if( hair != undefined){
                if(hair.type == Model.GOOD_TYPE_CAT){
                    Model.me.catHair = hair.hair;
                }else if( hair.type == Model.GOOD_TYPE_DOG){
                    Model.me.dogHair = hair.hair;
                }
            }
            var user = result.rsp.user;
            if( user ){
                Model.me.initFromData(user);
            }
            DiamondElement.getInstance().updateDisplay();

            if( GoldenFingerPanel.getInstance().parent)
                GoldenFingerPanel.getInstance().onWashBack(result);
        }

        public static onBattleRecord(result){
            Model.SYSTIME = result.date;
            BattleRecordPanel.getInstance().updateDisplay(result.rsp.list);
        }

        public static onWarBuffClear(result){
            Model.SYSTIME = result.date;
            var buffId:number = result.rsp.buffId;
            var param1:number = result.rsp.param1;
            var param2:number = result.rsp.param2;
            BuffMgr.getInstance().deleteBuff(0,buffId);
            if( MainScene.getInstance().parent)
                MainScene.getInstance().updateNoWarBuff();
            if(param1 == 0 ){
                window["__pillage"](param2);
            }else if( param1 == 1){
                window["__revenge"](param2);
            }

        }

        public static onPopularityAward(result){
            Model.SYSTIME = result.date;
            var user:any = result.rsp.user;
            if( user)
                Model.me.initFromData(user);
            // BigdataScene.getInstance().onMengAwardBack(0);
            PlayBar.getInstance().updateMeng();
        }

        public static onRobAward(result){
            Model.SYSTIME = result.date;
            var user:any = result.rsp.user;
            if( user)
                Model.me.initFromData(user);
            // BigdataScene.getInstance().onMengAwardBack(1);
            PlayBar.getInstance().updateMeng();
        }

        public static onResetPraise(result){
            Model.SYSTIME = result.date;
            var user:any = result.rsp.user;
            if( user)
                Model.me.initFromData(user);
            DiamondElement.getInstance().updateDisplay();
            Model.userExt =  result.rsp.info;
        }
       
        public static onDesktop(result){
            Model.SYSTIME = result.date;
            if( result.rsp.success){
                if( result.rsp.user){
                    Model.me.initFromData(result.rsp.user);
                    DiamondElement.getInstance().updateDisplay();
                }
                ShowHint("收藏成功，得到奖励：Vip积分*50，钻石*100");
            }
        }
   
        
        public static onLimitHairBack(result){
            Model.SYSTIME = result.date;
            MainScene.getInstance().onInfoBack(result.rsp.data);
        }
        public static onLimitHairBuyBack(result){
            Model.SYSTIME = result.date;
            MainScene.getInstance().onInfoBack(result.rsp.activityHair);
            var hair:any = result.rsp.petHair;
            if( hair != undefined){
                if(hair.type == Model.GOOD_TYPE_CAT){
                    Model.me.catHair = hair.hair;
                }else if( hair.type == Model.GOOD_TYPE_DOG){
                    Model.me.dogHair = hair.hair;
                }
                DiamondElement.getInstance().updateDisplay();
            }
        }
        public static onRichManInfo(result){
            Model.SYSTIME = result.date;
            ActivityMgr.getInstance().richmanInfo = result.rsp.data;
            if( RichMan.getInstance().parent){
                RichMan.getInstance().onInfoBack();
            }
        }
        public static onRichManGo(result){
            Model.SYSTIME = result.date;
            var user = result.rsp.user;
            if( user ){
                Model.me.diamond  = user.diamond;
                DiamondElement.getInstance().updateDisplay();
            }

            var prop:any = result.rsp.prop;
            if (prop != null) {
                var rawCnt = Model.GetPropCnt(prop.propId);

                if (  result.rsp.products == null){
                    result.rsp.products = {};
                }
                result.rsp.products[prop.propId] = prop.count - rawCnt;
                Model.updatePropCnt(prop.propId, prop.count);
            }
            var hair:any = result.rsp.hair;
            
            if( hair != undefined){
                if(hair.type == Model.GOOD_TYPE_CAT){
                    Model.me.catHair = hair.hair;
                }else if( hair.type == Model.GOOD_TYPE_DOG){
                    Model.me.dogHair = hair.hair;
                }
            }
            var diamond = result.rsp.diamond ? result.rsp.diamond : 0;
            RichMan.getInstance().onGoBack(result.rsp.track, result.rsp.products, diamond);
       }
        public static onLimitDecInfo(result) {
            Model.SYSTIME = result.date;
            LimitBuyDecorate.getInstance().onInfoBack(result.rsp.data);
        }
        public static onLimitDecBuy(result) {
            Model.SYSTIME = result.date;
            var user = result.rsp.user;
            if( user ){
                Model.me.diamond  = user.diamond;
                DiamondElement.getInstance().updateDisplay();
            }
            var ornaments = result.rsp.ornaments;
            if (ornaments) {
                var len = ornaments.length;
                var info;
                for(var i = 0; i < len; i++){
                    info = ornaments[i];
                    Model.updateDecorate(info);
                }
            }
            LimitBuyDecorate.getInstance().onBuyBack(result.rsp.activityOrnament);
            ShowHint("购买成功，请到装扮界面穿上");
        }
        public static heartBeat(hehe) {
            if( hehe == null) return;
            window["__buffs"]();
        }
    }
}
